home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / UNITS / JSTKA.ASM < prev    next >
Assembly Source File  |  1992-11-22  |  2KB  |  50 lines

  1. GAMEPORT       =      201h
  2.  
  3.                IDEAL
  4.            MODEL  large
  5.  
  6.                DATASEG
  7.                PUBLIC _jstk1_x, _jstk1_y, _jstk2_x, _jstk2_y
  8.                PUBLIC _jsense, _jrange
  9.  
  10. _jstk1_x       dw     0          ; joystick 1 x-axis
  11. _jstk1_y       dw     0          ; joystick 1 y-axis
  12. _jstk2_x       dw     0          ; joystick 2 x-axis
  13. _jstk2_y       dw     0          ; joystick 2 y-axis
  14. _jsense        dw     1          ; joystick sensitivity
  15. _jrange        dw     300        ; joystick range
  16.                CODESEG
  17.  
  18.                PUBLIC _read_jstk
  19. PROC           _read_jstk
  20.                mov    dx,GAMEPORT
  21.                out    dx,al          ;start timer
  22.                xor    ax,ax
  23.                mov    [_jstk1_x],ax  ;initialize to zero
  24.                mov    [_jstk1_y],ax  ;
  25.                mov    [_jstk2_x],ax  ;
  26.                mov    [_jstk2_y],ax  ;
  27.                mov    cx,[_jrange]   ;# times to iterate rangeloop
  28. rangeloop:
  29.                mov    bx,[_jsense]
  30. delay:
  31.                in     al,dx
  32.                dec    bx
  33.                jnz    delay
  34.  
  35.                shr    al,1
  36.                adc    [_jstk1_x],bx
  37.                shr    al,1
  38.                adc    [_jstk1_y],bx
  39.                shr    al,1
  40.                adc    [_jstk2_x],bx
  41.                shr    al,1
  42.                adc    [_jstk2_y],bx
  43.                loop   rangeloop
  44.                not    al
  45.                and    ax,0fh          ;return the button status in ax
  46.                ret
  47. ENDP           _read_jstk
  48.  
  49.                END
  50.